package com.pn.warehouse.service.impl;

import com.pn.warehouse.entity.Unit;
import com.pn.warehouse.mapper.UnitMapper;
import com.pn.warehouse.service.UnitService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@CacheConfig(cacheNames = "com.pn.warehouse.service.impl.UnitServiceImpl")
@Service
public class UnitServiceImpl implements UnitService {

    @Resource
    private UnitMapper unitMapper;

    //查询所有的单位
    @Cacheable(key = "'all:unit'")
    @Override
    public List<Unit> findAllUnit() {
        List<Unit> allUnit = unitMapper.findAllUnit();
        return allUnit;
    }

}
